package org.icosagon.ui.character;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.icosagon.ui.LabeledValue;
import org.icosagon.core.character.Character;
import org.icosagon.core.character.Class;

/**
 *
 */
public class GeneralPanel extends JPanel {
    private Character target = null;

    private LabeledValue name, player;

    public GeneralPanel(Character c) {
        this.target = c;
        this.setLayout(new GridBagLayout());
        GridBagConstraints con = new GridBagConstraints();

        this.name = new LabeledValue("Name", c.getName());
        this.player = new LabeledValue("Player", "");

        con.gridx = 0;
        con.gridy = 0;
        this.add(this.name, con);

        con.gridx = 1;
        this.add(this.player, con);

        con.gridx = 0;
        con.gridy = 1;
        this.add(new ClassPanel(), con);
    }

    private class ClassPanel extends JComponent {
        private JLabel label = new JLabel("Level:");

        public ClassPanel() {
            this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

            Font font = new Font(this.label.getFont().getName(),Font.BOLD,this.label.getFont().getSize());
            label.setFont(font);

            JComponent level = new JComponent() {};
            level.setLayout(new BoxLayout(level, BoxLayout.X_AXIS));
            level.add(label);
            level.add(new JLabel(String.valueOf(target.getLevel())));

            this.add(level);
            for(Class cl : target.getClasses()) {
                String text = "["+cl.getLevel()+"] "+cl.getName();
                this.add(new JLabel(text));
            }
        }
    }
}